<template>
  <div class="form-design-container">
    <fd-design-form ref="formDesign" :data="info.pageData"
                    :uploadPath ="uploadUrl" upload preview generate-code generate-json clearable>
    </fd-design-form>
  </div>
</template>

<script>
import {fieldsTemplateAnalysis} from "@/api/toolkit/form";
import  {getToken} from "@/utils/auth";

export default {
  name: "FormDesign",
  components: {

  },
  props: {
    info: {
      type: Object,
      default() {
        return {
          pageData: {}
        }
      }
    }
  },
  mounted() {
    if(this.info.pageData){
      this.info.pageData = JSON.parse(this.info.pageData);
      console.log(this.info.pageData)
      this.$refs.formDesign.setJSON(this.info.pageData)
    }
  },
  data() {
    return {
      uploadUrl: process.env.VUE_APP_BASE_API + '/system/fileInfo/upload',
      design: {
        visible: false,
        form: {
          action: fieldsTemplateAnalysis(),
          headers: {
            "h5ve": getToken()
          },
          accept: ".xlsx",
          limit: 1
        }
      }
    }
  },
  methods: {
    /**导出模板*/
    exportTemplate() {
      /*exportLocalFile({
        url: '/template.xlsx',
        suffix: ".xlsx",
        fileName: "模板"
      });*/
    }
  }
}
</script>

<style scoped lang="scss">
.form-design-container {
  height: calc(100vh - 45px);
  ::v-deep {
    .el-collapse {
      border-top: 0;
    }
  }
  .export-form {
    position: fixed;
    top: 10px;
    right: 252px;
    padding: 4px 12px;
    font-size: 18px;
    background-color: #e3efff;
    color: #409eff;
    border-radius: 3px;
    cursor: pointer;
  }
}
</style>
